package com.baidu.shoppingmall.role.service.Impl;

import com.baidu.shoppingmall.role.dao.PermissionDao;
import com.baidu.shoppingmall.role.domain.PermissionDTO;
import com.baidu.shoppingmall.role.domain.PermissionPO;
import com.baidu.shoppingmall.role.service.PermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionDao, PermissionPO> implements PermissionService {

    @Autowired
    private PermissionDao permissionDao;

    //根据用户id查询用户权限下的角色
    @Override
    public List<PermissionDTO> queryUser(String id) {
        List<PermissionPO> permissionPoList = permissionDao.queryUser(id);
        List<PermissionDTO> permissionDtoList = new ArrayList<>();
        permissionPoList.forEach(po->permissionDtoList.add(po.clone(PermissionDTO.class)));
        return permissionDtoList;
    }
}
